<?php
require_once 'BaseController.php';

class ErrorController extends BaseController {
	
	public function indexAction() {
		$status = $this->getRequest()->getParam('status',500);
		$error_obj = $this->getRequest()->getParam('error_obj');
		
		if(!is_object($error_obj)) {
			$this->toErrorLogs(urldecode($error_obj));
		}
		
		header('HTTP/1.1 ' . $status);
		$this->view->assign(array(
			'status'		=> $status,
			'title'			=> 'ERROR',
			'error_obj'		=> $error_obj
		));
		
		if(isset($_GET['direct_report']) && $_GET['direct_report'] == '100') {
			echo $error_obj;
			exit;
		}else {
			if($status == 500) {
				$this->alert_back('ERROR');
			}else {
				if(is_object($error_obj)) {
					$this->alert_back($error_obj->getMessage());
				}else {
					$this->alert_back(urldecode($error_obj));
				}
			}
		}
		exit;
	}
}